package com.whnk.web.controller.evo;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;
import com.whnk.evo.domain.ModInfo;
import com.whnk.evo.service.IModInfoService;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 模板 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-09-03
 */
@Controller
@RequestMapping("/evo/modInfo")
public class ModInfoController extends BaseController
{
    private String prefix = "evo/modInfo";
	
	@Autowired
	private IModInfoService modInfoService;
	
	@RequiresPermissions("evo:modInfo:view")
	@GetMapping()
	public String modInfo()
	{
	    return prefix + "/modInfo";
	}
	
	/**
	 * 查询模板列表
	 */
	@RequiresPermissions("evo:modInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ModInfo modInfo)
	{
		startPage();
        List<ModInfo> list = modInfoService.selectModInfoList(modInfo);
		return getDataTable(list);
	}
	
	/**
	 * 新增模板
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存模板
	 */
	@RequiresPermissions("evo:modInfo:add")
	@Log(title = "模板", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ModInfo modInfo)
	{		
		return toAjax(modInfoService.insertModInfo(modInfo));
	}

	/**
	 * 修改模板
	 */
	@GetMapping("/edit/{modId}")
	public String edit(@PathVariable("modId") Integer modId, ModelMap mmap)
	{
		ModInfo modInfo = modInfoService.selectModInfoById(modId);
		mmap.put("modInfo", modInfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存模板
	 */
	@RequiresPermissions("evo:modInfo:edit")
	@Log(title = "模板", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ModInfo modInfo)
	{		
		return toAjax(modInfoService.updateModInfo(modInfo));
	}
	
	/**
	 * 删除模板
	 */
	@RequiresPermissions("evo:modInfo:remove")
	@Log(title = "模板", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(modInfoService.deleteModInfoByIds(ids));
	}
	
}
